# replication file for
# "Ideological Positions and Committee Chair Appointments"
# published in Legislative Studies Quarterly
# authors: Jochen Rehmert & Naofumi Fujimura

# replicates
# Figure 2 and 3

# needs:
# ideol_data.dta

    
# directory 
wd <- "C:/..."
setwd(wd)
# prepare data
library(readstata13)
dat <- readstata13::read.dta13("ideol_data.dta")

dat$en_name <- as.character(dat$en_name)


#####################################
# Figure 2: a) Foreign Policy 2003  #
#####################################

par(mar = c(4,4,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2003,], xlab = "Economic Policy Dimension",  main = "",
     ylab = "Foreign Policy Dimension", xlim = c(-3,3), ylim = c(-3,3), frame = F,  cex = 1)
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier
out.pc1.2003 <- dat[which(abs(dat$PC1) >  (abs(mean(dat$PC1[dat$year == 2003], na.rm = TRUE)) + sd(dat$PC1[dat$year == 2003], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "pid", "year")  ]
out.pc2.2003 <- dat[which(abs(dat$PC2) >  (abs(mean(dat$PC2[dat$year == 2003], na.rm = TRUE)) + sd(dat$PC2[dat$year == 2003], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "pid", "year")  ]
# points(PC1 ~ PC2, data = out.pc1.2003[out.pc1.2003$year == 2003,], col = "black")
text(x = out.pc1.2003$PC2[out.pc1.2003$year == 2003][1] -0.2, 
     y = out.pc1.2003$PC1[out.pc1.2003$year == 2003][1] -0.2, 
     labels = out.pc1.2003$en_name[out.pc1.2003$year == 2003][1], cex = 0.7)
points(out.pc1.2003$PC1[out.pc1.2003$year == 2003][1] ~  out.pc1.2003$PC2[out.pc1.2003$year == 2003][1], pch = 19)
text(x = out.pc1.2003$PC2[out.pc1.2003$year == 2003][2] -0.3, 
     y = out.pc1.2003$PC1[out.pc1.2003$year == 2003][2] -0.2, 
     labels = out.pc1.2003$en_name[out.pc1.2003$year == 2003][2], cex = 0.7)
points(out.pc1.2003$PC1[out.pc1.2003$year == 2003][2] ~ out.pc1.2003$PC2[out.pc1.2003$year == 2003][2], pch = 19)
text(x = out.pc1.2003$PC2[out.pc1.2003$year == 2003][3] - 0.2, 
     y = out.pc1.2003$PC1[out.pc1.2003$year == 2003][3] - 0.2, 
     labels = out.pc1.2003$en_name[out.pc1.2003$year == 2003][3], cex = 0.7)
points(out.pc1.2003$PC1[out.pc1.2003$year == 2003][3] ~ out.pc1.2003$PC2[out.pc1.2003$year == 2003][3], pch = 19)
text(x = out.pc1.2003$PC2[out.pc1.2003$year == 2003][4] + .2, 
     y = out.pc1.2003$PC1[out.pc1.2003$year == 2003][4] + .2, 
     labels = out.pc1.2003$en_name[out.pc1.2003$year == 2003][4], cex = 0.7)
points(out.pc1.2003$PC1[out.pc1.2003$year == 2003][4] ~ out.pc1.2003$PC2[out.pc1.2003$year == 2003][4], pch = 19)
text(x = out.pc1.2003$PC2[out.pc1.2003$year == 2003][5] + 0.1, 
     y = out.pc1.2003$PC1[out.pc1.2003$year == 2003][5] + 0.2, 
     labels = out.pc1.2003$en_name[out.pc1.2003$year == 2003][5], cex = 0.7)
points(out.pc1.2003$PC1[out.pc1.2003$year == 2003][5] ~ out.pc1.2003$PC2[out.pc1.2003$year == 2003][5], pch = 19)



#####################################
# Figure 2: b) Economic Policy 2003 #
#####################################

par(mar = c(4,1,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2003,],  xlab = "Economic Policy Dimension",  main = "",
     ylab = "", xlim = c(-3,3), ylim = c(-3,3), frame = F, yaxt = "n" )
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
#axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier
out.pc2.2003 <- out.pc2.2003[out.pc2.2003$year == 2003 , ]
out.pc2.2003 <- out.pc2.2003[-1, ]

text(x = out.pc2.2003$PC2[out.pc2.2003$year == 2003][1] -0.2, 
     y = out.pc2.2003$PC1[out.pc2.2003$year == 2003][1] -0.2, 
     labels = out.pc2.2003$en_name[out.pc2.2003$year == 2003][1], cex = 0.7)
points(out.pc2.2003$PC1[out.pc1.2003$year == 2003][1] ~  out.pc2.2003$PC2[out.pc1.2003$year == 2003][1], pch = 19)
text(x = out.pc2.2003$PC2[out.pc2.2003$year == 2003][2] -0.3, 
     y = out.pc2.2003$PC1[out.pc2.2003$year == 2003][2] -0.2, 
     labels = out.pc2.2003$en_name[out.pc2.2003$year == 2003][2], cex = 0.7)
points(out.pc2.2003$PC1[out.pc1.2003$year == 2003][2] ~  out.pc2.2003$PC2[out.pc1.2003$year == 2003][2], pch = 19)
text(x = out.pc2.2003$PC2[out.pc2.2003$year == 2003][3] -0.3, 
     y = out.pc2.2003$PC1[out.pc2.2003$year == 2003][3] -0.2, 
     labels = out.pc2.2003$en_name[out.pc2.2003$year == 2003][3], cex = 0.7)
points(out.pc2.2003$PC1[out.pc1.2003$year == 2003][3] ~  out.pc2.2003$PC2[out.pc1.2003$year == 2003][3], pch = 19)
text(x = out.pc2.2003$PC2[out.pc2.2003$year == 2003][4], 
     y = out.pc2.2003$PC1[out.pc2.2003$year == 2003][4] -0.2, 
     labels = out.pc2.2003$en_name[out.pc2.2003$year == 2003][4], cex = 0.7)
points(out.pc2.2003$PC1[out.pc1.2003$year == 2003][4] ~  out.pc2.2003$PC2[out.pc1.2003$year == 2003][4], pch = 19)
text(x = out.pc2.2003$PC2[out.pc2.2003$year == 2003][5], 
     y = out.pc2.2003$PC1[out.pc2.2003$year == 2003][5] +0.2, 
     labels = out.pc2.2003$en_name[out.pc2.2003$year == 2003][5], cex = 0.7)
points(out.pc2.2003$PC1[out.pc1.2003$year == 2003][5] ~  out.pc2.2003$PC2[out.pc1.2003$year == 2003][5], pch = 19)

####################################
# Figure 2: c) Foreign Policy 2005 #
####################################

par(mar = c(4,4,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2005,], xlab = "Economic Policy Dimension",  main = "",
     ylab = "Foreign Policy Dimension", xlim = c(-3,3), ylim = c(-3,3), frame = F)
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier
out.pc1.2005 <- dat[which(abs(dat$PC1) >  (abs(mean(dat$PC1[dat$year == 2005], na.rm = TRUE)) + sd(dat$PC1[dat$year == 2005], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "year")  ]
out.pc2.2005 <- dat[which(abs(dat$PC2) >  (abs(mean(dat$PC2[dat$year == 2005], na.rm = TRUE)) + sd(dat$PC2[dat$year == 2005], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "year")  ]

# KAMIKAWA, YOKO
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][1], 
     y = out.pc1.2005$PC1[out.pc1.2005$year == 2005][1] -0.2, 
     labels = out.pc1.2005$en_name[out.pc1.2005$year == 2005][1], cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][1] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][1], pch = 19)

# NAKAGAWA, HIDENAO
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][2]+0.7, 
     y = out.pc1.2005$PC1[out.pc1.2005$year == 2005][2], 
     labels = out.pc1.2005$en_name[out.pc1.2005$year == 2005][2], cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][2] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][2], pch = 19)

# IWAKI, NOBUKO
text(x = -2.4, 
     y = -2.3, 
     labels = "IWAKI, NOBUKO &\n SATO, REN", cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][3] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][3], pch = 19)


# KITAMURA, SHIGEO
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][5]+0.45, 
     y = out.pc1.2005$PC1[out.pc1.2005$year == 2005][5]-0.2, 
     labels = out.pc1.2005$en_name[out.pc1.2005$year == 2005][5], cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][5] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][5], pch = 19)

# YOSHIDA, ROKUZAEMON
text(x = -2.2, 
     y = -1.5, 
     labels = "YOSHIDA,\nROKUZAEMON", cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][6] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][6], pch = 19)
segments(x0 = out.pc1.2005$PC2[out.pc1.2005$year == 2005][6], x1 = -1.85, 
         y0 = out.pc1.2005$PC1[out.pc1.2005$year == 2005][6], y1 = -1.6)

# TAIRA, MASAAKI
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][7]+0.15, 
     y = out.pc1.2005$PC1[out.pc1.2005$year == 2005][7] -0.2, 
     labels = out.pc1.2005$en_name[out.pc1.2005$year == 2005][7], cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][7] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][7], pch = 19)

# SUGIMURA, TAIZO
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][8], 
     y = out.pc1.2005$PC1[out.pc1.2005$year == 2005][8] -0.2, 
     labels = "SUGIMURA, TAIZO", cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][8] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][8], pch = 19)

# IZUHARA, YASUJI
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][9], 
     y = -2.5, 
     labels = out.pc1.2005$en_name[out.pc1.2005$year == 2005][9], cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][9] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][9], pch = 19)
segments(x0 = out.pc1.2005$PC2[out.pc1.2005$year == 2005][9], x1 = out.pc1.2005$PC2[out.pc1.2005$year == 2005][9], 
         y0 = out.pc1.2005$PC1[out.pc1.2005$year == 2005][9], y1 = -2.4)

# ENDO, NOBUHIKO
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][11], 
     y = -2.4, 
     labels = "ENDO, NOBUHIKO &\n NISHIKAWA, KYOKO", cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][11] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][11], pch = 19)
segments(x0 = out.pc1.2005$PC2[out.pc1.2005$year == 2005][11], x1 = out.pc1.2005$PC2[out.pc1.2005$year == 2005][11], 
         y0 = out.pc1.2005$PC1[out.pc1.2005$year == 2005][11], y1 =  -2.2)

# ENDO, TAKEHIKO
text(x = out.pc1.2005$PC2[out.pc1.2005$year == 2005][12]+0.1, 
     y = out.pc1.2005$PC1[out.pc1.2005$year == 2005][12]-0.2, 
     labels = out.pc1.2005$en_name[out.pc1.2005$year == 2005][12], cex = 0.7)
points(out.pc1.2005$PC1[out.pc1.2005$year == 2005][12] ~  out.pc1.2005$PC2[out.pc1.2005$year == 2005][12], pch = 19)


#####################################
# Figure 2: d) Economic Policy 2005 #
#####################################

par(mar = c(4,1,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2005,], xlab = "Economic Policy Dimension",  main = "",
     ylab = "Foreign Policy Dimension", xlim = c(-3,3), ylim = c(-3,3), frame = F, yaxt = "n")
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
#axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier

# NAKANO, KIYOSHI
text(x = -2.9, 
     y = -1.0, 
     labels = "NAKANO,\nKIYOSHI", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][1] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][1], pch = 19)
segments(x0 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][1], x1 = -2.7, 
         y0 = out.pc2.2005$PC1[out.pc2.2005$year == 2005][1], y1 = -1)


# ETO, SEISHIRO
text(x = -2.9, 
     y = -1.6, 
     labels = "ETO,\nSEISHIRO", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][10] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][10], pch = 19)
segments(x0 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][10], x1 = -2.8, 
         y0 = out.pc2.2005$PC1[out.pc2.2005$year == 2005][10], y1 = -1.5)

# IWAKI, NOBUKO
text(x = -1.4, 
     y = -2.6, 
     labels = "IWAKI, NOBUKO", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][2] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][2], pch = 19)
segments(x0 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][2], x1 = -1.3, 
         y0 = out.pc2.2005$PC1[out.pc2.2005$year == 2005][2], y1 = -2.5)

# SATO, REN
text(x = -2.3, 
     y = -3, 
     labels = out.pc2.2005$en_name[out.pc2.2005$year == 2005][4], cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][4] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][4], pch = 19)
segments(x0 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][4], x1 = -2.2, 
         y0 = out.pc2.2005$PC1[out.pc2.2005$year == 2005][4], y1 = -2.9)

# SATA, GENICHIRO
text(x = out.pc2.2005$PC2[out.pc2.2005$year == 2005][3]-0.1, 
     y = 1, 
     labels = out.pc2.2005$en_name[out.pc2.2005$year == 2005][3], cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][3] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][3], pch = 19)
segments(x0 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][3], x1 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][3], 
         y0 = out.pc2.2005$PC1[out.pc2.2005$year == 2005][3], y1 = 0.9)

# YASUI, JUNICHIRO
text(x =out.pc2.2005$PC2[out.pc2.2005$year == 2005][5], 
     y =out.pc2.2005$PC1[out.pc2.2005$year == 2005][5] + 0.2, 
     labels = "YASUI, JUNICHIRO", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][5] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][5], pch = 19)

# SUGIMURA, TAIZO
text(x = out.pc2.2005$PC2[out.pc2.2005$year == 2005][6], 
     y = out.pc2.2005$PC1[out.pc2.2005$year == 2005][6]-0.2, 
     labels = "SUGIMURA, TAIZO", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][6] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][6], pch = 19)



# HAYASHIDA, TAKESHI
text(x = out.pc2.2005$PC2[out.pc2.2005$year == 2005][7]-0.4, 
     y = out.pc2.2005$PC1[out.pc2.2005$year == 2005][7]+0.1, 
     labels = "HAYASHIDA,\nTAKESHI", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][7] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][7], pch = 19)


# MUTO, YOJI
text(x = -2.9, 
     y = -2.6, 
     labels = out.pc2.2005$en_name[out.pc2.2005$year == 2005][8], cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][8] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][8], pch = 19)
segments(x0 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][8], x1 = -2.8, 
         y0 = out.pc2.2005$PC1[out.pc2.2005$year == 2005][8], y1 = -2.5)


# WATANABE, KOZOE
text(x = out.pc2.2005$PC2[out.pc2.2005$year == 2005][9]+0.7, 
     y = 2, 
     labels = "WATANABE, KOZOE", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][9] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][9], pch = 19)
segments(x0 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][9], x1 = out.pc2.2005$PC2[out.pc2.2005$year == 2005][9]+0.6, 
         y0 = out.pc2.2005$PC1[out.pc2.2005$year == 2005][9], y1 = 1.9)

# SUZUKI, KEISUKE
text(x = out.pc2.2005$PC2[out.pc2.2005$year == 2005][11], 
     y = out.pc2.2005$PC1[out.pc2.2005$year == 2005][11]+0.2, 
     labels = "SUZUKI, KEISUKE", cex = 0.7)
points(out.pc2.2005$PC1[out.pc2.2005$year == 2005][11] ~  out.pc2.2005$PC2[out.pc2.2005$year == 2005][11], pch = 19)


####################################
# Figure 3: a) Foreign Policy 2012 #
####################################

par(mar = c(4,4,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2012,], xlab = "Economic Policy Dimension",  main = "",
     ylab = "Foreign Policy Dimension", xlim = c(-3,3), ylim = c(-3,3.2), frame = F)
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier
out.pc1.2012 <- dat[which(abs(dat$PC1) >  (abs(mean(dat$PC1[dat$year == 2012], na.rm = TRUE)) + sd(dat$PC1[dat$year == 2012], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "year")  ]
out.pc2.2012 <- dat[which(abs(dat$PC2) >  (abs(mean(dat$PC2[dat$year == 2012], na.rm = TRUE)) + sd(dat$PC2[dat$year == 2012], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "year")  ]

# MIYAZAKI, MASAHISA
text(x = out.pc1.2012$PC2[out.pc1.2012$year == 2012][1], 
     y = out.pc1.2012$PC1[out.pc1.2012$year == 2012][1]-0.2, 
     labels = "MIYAZAKI, MASAHISA", cex = 0.7)
points(out.pc1.2012$PC1[out.pc1.2012$year == 2012][1] ~ out.pc1.2012$PC2[out.pc1.2012$year == 2012][1], pch = 19)

# KOIKE, YURIKO
text(x = out.pc1.2012$PC2[out.pc1.2012$year == 2012][2]+0.6, 
     y = out.pc1.2012$PC1[out.pc1.2012$year == 2012][2], 
     labels = "KOIKE, YURIKO", cex = 0.7)
points(out.pc1.2012$PC1[out.pc1.2012$year == 2012][2] ~ out.pc1.2012$PC2[out.pc1.2012$year == 2012][2], pch = 19)

# HOSHINO, TSUYOSHI
text(x = out.pc1.2012$PC2[out.pc1.2012$year == 2012][3], 
     y = out.pc1.2012$PC1[out.pc1.2012$year == 2012][3]-0.2, 
     labels = "HOSHINO, TSUYOSHI", cex = 0.7)
points(out.pc1.2012$PC1[out.pc1.2012$year == 2012][3] ~ out.pc1.2012$PC2[out.pc1.2012$year == 2012][3], pch = 19)

# SAKURADA, YOSHITAKA
text(x = out.pc1.2012$PC2[out.pc1.2012$year == 2012][4], 
     y = out.pc1.2012$PC1[out.pc1.2012$year == 2012][4]-0.2, 
     labels = "SAKURADA, YOSHITAKA", cex = 0.7)
points(out.pc1.2012$PC1[out.pc1.2012$year == 2012][4] ~ out.pc1.2012$PC2[out.pc1.2012$year == 2012][4], pch = 19)

# IZUHARA, YASUJI
text(x = out.pc1.2012$PC2[out.pc1.2012$year == 2012][5], 
     y = out.pc1.2012$PC1[out.pc1.2012$year == 2012][5]+0.2, 
     labels = "IZUHARA, YASUJI", cex = 0.7)
points(out.pc1.2012$PC1[out.pc1.2012$year == 2012][5] ~ out.pc1.2012$PC2[out.pc1.2012$year == 2012][5], pch = 19)

# SUZUKI, KEISUKE
text(x = out.pc1.2012$PC2[out.pc1.2012$year == 2012][6]-0.2, 
     y = out.pc1.2012$PC1[out.pc1.2012$year == 2012][6]+0.2, 
     labels = "SUZUKI, KEISUKE", cex = 0.7)
points(out.pc1.2012$PC1[out.pc1.2012$year == 2012][6] ~ out.pc1.2012$PC2[out.pc1.2012$year == 2012][6], pch = 19)


#####################################
# Figure 3: b) Economic Policy 2012 #
#####################################

par(mar = c(4,1,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2012,], xlab = "Economic Policy Dimension",  main = "",
     ylab = "", xlim = c(-3,3), ylim = c(-3,3.2), frame = F, yaxt = "n")
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
#axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier

# YAMAMOTO, TOMOHIRO
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][1], 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][1]-0.2, 
     labels = "YAMAMOTO, TOMOHIRO", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][1] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][1], pch = 19)

# YAMAGIWA, DAISHIRO
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][2]-0.4, 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][2]-0.45, 
     labels = "YAMAGIWA, DAISHIRO", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][2] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][2], pch = 19)
segments(x0 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][2], x1 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][2]-0.3,
         y0 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][2], y1 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][2]-0.3)

# SHINTANI, MASAYOSHI
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][3], 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][3]-0.2, 
     labels = "SHINTANI, MASAYOSHI", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][3] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][3], pch = 19)

# MURAI, HIDEKI
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][4]-0.1, 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][4]+0.8, 
     labels = "MURAI, HIDEKI", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][4] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][4], pch = 19)
segments(x0 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][4], x1 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][4] -0.1,
         y0 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][4], y1 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][4]+0.7)

# SHIMIZU, SEIICHI
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][5]-0.5, 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][5]+0.2, 
     labels = "SHIMIZU, SEIICHI &\n WATANABE, KOICHI", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][5] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][5], pch = 19)

# TANAKA, YOSHIO
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][7]-1, 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][7], 
     labels = "TANAKA, YOSHIO", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][7] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][7], pch = 19)
segments(x0 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][7], x1 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][7]-0.5,
         y0 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][7], y1 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][7])

# FUKUDA, MINEYUKI
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][8]-1, 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][8]-.9, 
     labels = "FUKUDA, MINEYUKI", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][8] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][8], pch = 19)
segments(x0 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][8], x1 = out.pc2.2012$PC2[out.pc2.2012$year == 2012][8]-0.9,
         y0 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][8], y1 = out.pc2.2012$PC1[out.pc2.2012$year == 2012][8]-.7)

# OCHI, TAKAO
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][9]+0.35, 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][9]+0.15, 
     labels = "OCHI, TAKAO", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][9] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][9], pch = 19)

# SUZUKI, KEISUKE
text(x = out.pc2.2012$PC2[out.pc2.2012$year == 2012][10]-0.2, 
     y = out.pc2.2012$PC1[out.pc2.2012$year == 2012][10]+0.2, 
     labels = "SUZUKI, KEISUKE", cex = 0.7)
points(out.pc2.2012$PC1[out.pc2.2012$year == 2012][10] ~ out.pc2.2012$PC2[out.pc2.2012$year == 2012][10], pch = 19)



####################################
# Figure 3: c) Foreign Policy 2014 #
####################################


par(mar = c(4,4,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2014,], xlab = "Economic Policy Dimension",  main = "",
     ylab = "Foreign Policy Dimension", xlim = c(-3.1,3.5), ylim = c(-3,3), frame = F)
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier
out.pc1.2014 <- dat[which(abs(dat$PC1) >  (abs(mean(dat$PC1[dat$year == 2014], na.rm = TRUE)) + sd(dat$PC1[dat$year == 2014], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "year", "pid")  ]
out.pc2.2014 <- dat[which(abs(dat$PC2) >  (abs(mean(dat$PC2[dat$year == 2014], na.rm = TRUE)) + sd(dat$PC2[dat$year == 2014], na.rm = TRUE)*2)),c("PC1","PC2","en_name", "year", "pid")  ]

# YASUOKA, OKIHARU
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][1], 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][1]-.9, 
     labels = "YASUOKA, OKIHARU", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][1] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][1], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][1], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][1],
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][1], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][1]-.8)

# KATO, AYUKO
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][2], 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][2]+0.2, 
     labels = "KATO, AYUKO", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][2] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][2], pch = 19)

# SAKAMOTO, TETSUSHI
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][3]+2.2, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][3]+1.5, 
     labels = "SAKAMOTO, TETSUSHI", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][3] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][3], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][3], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][3]+2.1,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][3], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][3]+1.4)

# OKONOGI, HACHIRO
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][5]-2.3, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][5]+1.7, 
     labels = "KAWAI, KATSUYUKI &\nOKONOGI, HACHIRO", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][5] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][5], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][5], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][5]-1.9,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][5], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][5]+1.5)

# KOIKE, YURIKO
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][6]-1.3, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][6]-0.8, 
     labels = "KOIKE, YURIKO", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][6] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][6], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][6], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][6]-1.2,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][6], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][6]-0.7)

# ODAWARA, KIYOSHI
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][7]-1.1, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][7], 
     labels = "ODAWARA, KIYOSHI &\nKOJIMA, TOSHIFUMI", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][7] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][7], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][7], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][7]-0.5,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][7], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][7])

# SAKURADA, YOSHITAKA
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][8]+.4, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][8]-.5, 
     labels = "SAKURADA, YOSHITAKA", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][8] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][8], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][8], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][8]+0.3,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][8], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][8]-.4)

# TSUSHIMA, JUN
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][10], 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][10]-0.2, 
     labels = "TSUSHIMA, JUN", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][10] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][10], pch = 19)

# MACHIMURA, NOBUTAKA
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][11]-2.1, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][11]+0.7, 
     labels = "MACHIMURA, NOBUTAKA &\n ISHIKAWA, AKIMASA", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][11] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][11], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][11], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][11]-1.4,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][11], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][11]+.675)

# AKAEDA, TSUNEO
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][13]+2.4, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][13]+0.6, 
     labels = "AKAEDA, TSUNEO", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][13] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][13], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][13], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][13]+2.0,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][13], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][13]+0.5)

# TSUJI, KIYOTO
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][14]+.8, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][14], 
     labels = "TSUJI, KIYOTO", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][14] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][14], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][14], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][14]+.3,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][14], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][14])

# SUZUKI, KEISUKE
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][15]-.5, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][15]+0.2, 
     labels = "SUZUKI, KEISUKE", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][15] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][15], pch = 19)

# KIKAWADA, HITOSHI
text(x = out.pc1.2014$PC2[out.pc1.2014$year == 2014][16]-0.5, 
     y = out.pc1.2014$PC1[out.pc1.2014$year == 2014][16]-.6, 
     labels = "KIKAWADA,\nHITOSHI", cex = 0.7)
points(out.pc1.2014$PC1[out.pc1.2014$year == 2014][16] ~ out.pc1.2014$PC2[out.pc1.2014$year == 2014][16], pch = 19)
segments(x0 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][16], x1 = out.pc1.2014$PC2[out.pc1.2014$year == 2014][16]-0.3,
         y0 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][16], y1 = out.pc1.2014$PC1[out.pc1.2014$year == 2014][16]-0.4)


#####################################
# Figure 3: d) Economic Policy 2014 #
#####################################

par(mar = c(4,1,1,1))
plot(PC1 ~ PC2, data = dat[dat$year == 2014,], xlab = "Economic Policy Dimension", main = "",
     ylab = "", xlim = c(-3,3.5), ylim = c(-3,3), frame = F, yaxt = "n")
axis(1, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
#axis(2, seq(-4,4,1), seq(-4,4,1), col.ticks = "black",col = "white")
# outlier

# HORII, MANABU
text(x = out.pc2.2014$PC2[out.pc2.2014$year == 2014][1], 
     y = out.pc2.2014$PC1[out.pc2.2014$year == 2014][1]-.2, 
     labels = "HORII, MANABU", cex = 0.7)
points(out.pc2.2014$PC1[out.pc2.2014$year == 2014][1] ~ out.pc2.2014$PC2[out.pc2.2014$year == 2014][1], pch = 19)

# TAIRA, MASAAKI
text(x = out.pc2.2014$PC2[out.pc2.2014$year == 2014][2], 
     y = out.pc2.2014$PC1[out.pc2.2014$year == 2014][2]-.2, 
     labels = "TAIRA, MASAAKI", cex = 0.7)
points(out.pc2.2014$PC1[out.pc2.2014$year == 2014][2] ~ out.pc2.2014$PC2[out.pc2.2014$year == 2014][2], pch = 19)

# SUZUKI, KEISUKE
text(x = out.pc2.2014$PC2[out.pc2.2014$year == 2014][3]-0.6, 
     y = out.pc2.2014$PC1[out.pc2.2014$year == 2014][3]+.2, 
     labels = "SUZUKI, KEISUKE", cex = 0.7)
points(out.pc2.2014$PC1[out.pc2.2014$year == 2014][3] ~ out.pc2.2014$PC2[out.pc2.2014$year == 2014][3], pch = 19)





